// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axiosInit from './utils/interceptor'
import ElementUI from 'element-ui'

import config from '@/config'
import moment from 'moment'

// import L from 'leaflet'

window.APP_VER = '20200324001'

Vue.prototype.$config = config
Vue.prototype.$m = moment
Vue.config.productionTip = false
Vue.use(ElementUI)

axiosInit(true, true)

window.apiPath = '/api'

router.beforeEach((to, from, next) => {
  if (to.matched.some(r => !r.meta.allowAnonymous)) {
    if (!localStorage.token) {
      next('/login')
      return
    }
  }
  next()
})

/* eslint-disable no-new */
new Vue({
  router,
  data: {eventHub: new Vue()},
  render: h => h(App)
}).$mount('#app')
